﻿@page "/counter"
@using Prism.Events
@using BlazorEventAggregator.Models
@inject IEventAggregator eventAggregator

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {
    int currentCount = 0;

    void IncrementCount()
    {
        currentCount++;

        if (currentCount % 2 == 0)
        {
            eventAggregator.GetEvent<ShowLoginEvent>().Publish(new ShowLoginEventPayload()
            {
                IsShow = true
            });
            eventAggregator.GetEvent<ShowLogoutEvent>().Publish(new ShowLogoutEventPayload()
            {
                IsShow = false
            });
        }
        else
        {
            eventAggregator.GetEvent<ShowLoginEvent>().Publish(new ShowLoginEventPayload()
            {
                IsShow = false
            });
            eventAggregator.GetEvent<ShowLogoutEvent>().Publish(new ShowLogoutEventPayload()
            {
                IsShow = true
            });
        }
    }
}
